package com.ld.security.shop.crawler.modules.wo.job;

import cn.hutool.core.lang.Console;
import com.ld.security.common.core.base.vo.DataVo;
import com.ld.security.common.core.util.SpringUtil;
import com.ld.security.common.quartz.modules.job.job.SuperJob;
import com.ld.security.shop.crawler.modules.wo.api.WoGroupApi;
import com.ld.security.shop.crawler.modules.wo.po.TaskDispatchPo;
import jdk.nashorn.internal.runtime.regexp.JoniRegExp;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;

import java.util.Arrays;

@Slf4j
public class WoGroupJob extends SuperJob {


    @Override
    public boolean before(JobExecutionContext jobExecutionContext) {
        WoGroupApi api = SpringUtil.getBean(WoGroupApi.class);

        JobDataMap map =  jobExecutionContext.getMergedJobDataMap();

        String id =(String)map.get("woGroupId");

        if(id != null){
            TaskDispatchPo po = new TaskDispatchPo();
            po.setGroupId(Arrays.asList(id));
            DataVo vo =api.dispatch(po);
            log.info(vo.getMessage());
        }


        Console.log("自定义作业执行");
        return super.before(jobExecutionContext);
    }
}
